home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Utilities / Installers / InstallerMaker™ 3.0 / Preinstalled version / Customizing InstallerMaker / Sample Code / IPkg & IBeg Example / IPkgIBEG.c < prev   
Encoding:
C/C++ Source or Header  |  1995-08-03  |  3.6 KB  |  139 lines  |  [TEXT/MMCC]

  1. /******************************************************************************
  2. **
  3. **  Project Name:    IPkg WWDC Demo
  4. **     File Name:    IPkgIBEG.c
  5. **
  6. **   Description:    IBeg routine that prepares the PKgs for the IPkg demo
  7. **
  8. **   Copyright© 1995 Aladdin Systems, inc.
  9. **
  10. *******************************************************************************
  11. **                       A U T H O R   I D E N T I T Y
  12. *******************************************************************************
  13. **
  14. **    Initials    Name
  15. **    --------    -----------------------------------------------
  16. **    RMT            Robert Thorne
  17. **
  18. *******************************************************************************
  19. **                      R E V I S I O N   H I S T O R Y
  20. *******************************************************************************
  21. **
  22. **      Date        Time    Author    Description
  23. **    --------    -----    ------    ---------------------------------------------
  24. **    05/03/95            RMT        Moved scraps into MW framework
  25. **
  26. ******************************************************************************/
  27.  
  28. #include "IMPackages256.h"
  29. #include "IPkgDemo.h"
  30. #include <Strings.h>
  31. #include "A4Globals.h" /* Quick trick to let us compile and test easier */
  32.  
  33. #if !GLOBALS_ALWAYS_AVAILABLE
  34.     #define IBEG_MAIN main
  35. #endif
  36.  
  37. #include "IMExtensionsFor3_0.h"
  38.  
  39. #define kDemoStrLen 40
  40.  
  41. pascal short IBEG_MAIN (unsigned char *pw , 
  42.                         unsigned long *refCon )
  43. {
  44.     long            oldA4 ;
  45.     short            rslt ;
  46.         
  47.     // If we're running as a resource, we establish our A4 world here
  48.     MAIN_SETUP_GLOBALS(oldA4) ;
  49.     
  50.     rslt = IBegMain (pw, refCon) ;
  51.  
  52.     MAIN_RESTORE_GLOBALS(oldA4) ;
  53.     
  54.     return rslt ;
  55.     
  56. }
  57.     
  58.  
  59. short IBegMain ( Str255 password, unsigned long *refCon )
  60. {
  61.     DialogPtr        dlg ;
  62.     Handle            textH = nil ;
  63.     unsigned long     **packDataH = nil ;
  64.     unsigned long    packages [4], newPackages [4] = {0,0,0,0} ;
  65.     Str255            packListStr ;
  66.     char            *listCPtr ;
  67.     Rect            itemRect ;
  68.     short            itemHit, itemType ;
  69.     short            i ;
  70.     
  71.     // Get our current package setting. Don't release this resource handle!
  72.     packDataH = (unsigned long     **) GetPackagesFromPKgs (kPKgsID, packages ) ;
  73.     
  74.     
  75.     if ( !packDataH )
  76.         return 0 ; // allow installation to procede, but bail
  77.         
  78.     // Construct a package string
  79.     listCPtr = (char *) packListStr ;
  80.     
  81.     (void) ConstructPkgString ( packages, listCPtr, kDemoStrLen) ; 
  82.     
  83.     c2pstr ( listCPtr ) ; // packListStr is ready to roll.  Check length for
  84.                           // safety, though.
  85.     
  86.     
  87.     
  88.     //Create a dialog structure
  89.     dlg = GetNewDialog ( kPKgsID, nil, (WindowPtr) -1 ) ;
  90.     
  91.     if (!dlg)
  92.         return 1 ; // something bad; abort installation.
  93.     
  94.     SetPort (dlg) ;
  95.     
  96.     GetDItem ( dlg , iIBegStrItem , &itemType , &textH , &itemRect ) ;
  97.     
  98.     if (packListStr [0] != kDemoStrLen ) // check to see if we were clipped
  99.         SetDialogItemText (textH, packListStr ) ;
  100.         
  101.     SelectDialogItemText ( dlg, iIBegStrItem, 0, 32767 ) ; // select all of its text
  102.  
  103.  
  104.     SetDialogDefaultItem ( dlg , ok ) ;
  105.     SetDialogCancelItem ( dlg , cancel ) ;
  106.     SetDialogTracksCursor ( dlg , true ) ;
  107.     
  108.     
  109.     //Do our modal dialog loop.  We don't test for data yet.
  110.     do 
  111.     {
  112.         ModalDialog ( nil, &itemHit ) ;
  113.         
  114.     } while ( itemHit != ok && itemHit != cancel ) ;
  115.     
  116.     // Now process our new package string if needed
  117.     if ( itemHit == ok )
  118.     {
  119.         GetIText ( textH , packListStr ) ;
  120.         
  121.         if (ParsePackageString ( newPackages, packListStr))
  122.         {
  123.             // we have a valid string, so alter data in resource handle
  124.             for ( i=0 ; i < 4 ; i++ )
  125.                 (*packDataH)[i] = newPackages [i] ;
  126.                 
  127.             // note that we don't call ChangedResource.  This is deliberate:
  128.             // the resource is now marked unpurgeable, so it will stay around.
  129.             // On the other hand, we don't want the resource to get written
  130.             // back, to allow for read-only installers.
  131.         }
  132.     }
  133.     
  134.     
  135.     DisposDialog (dlg) ;
  136.  
  137. }
  138.  
  139.